<?php 

class _F_EXTENSION_DATA_SELECT_ extends _F_OBJECT_ {
	
	public $db;
	public $class;
	public $select;
	public $from;
	public $where;
	public $order;
	public $first;
	public $limit;
	public $params;
	
	public function __construct($db,$query,$params,$class) {
		$this->db = $db;
		$this->class = $class;
		$this->put_properties($query);
		$this->params = $params;
	}
	
	public function select($value = null) {
		if (func_num_args()) {
			$this->select = $value;
			return $this;
		}
		return $this->select;
	}

	public function from($value = null) {
		if (func_num_args()) {
			$this->select = $value;
			return $this;
		}
		return $this->select;
	}

	public function where($value = null) {
		if (func_num_args()) {
			$this->where = $value;
			return $this;
		}
		return $this->where;
	}

	public function order($value = null) {
		if (func_num_args()) {
			$this->order = $value;
			return $this;
		}
		return $this->order;
	}

	public function first($value = null) {
		if (func_num_args()) {
			$this->first = $value;
			return $this;
		}
		return $this->first;
	}

	public function limit($value = null) {
		if (func_num_args()) {
			$this->limit = $value;
			return $this;
		}
		return $this->limit;
	}
	
	public function param($name,$value) {
		$this->params[$name] = $value;
		return $this;
	}
	
	public function params($params) {
		foreach ($params as $name => $value) 
			$this->params[$name] = $value;
		return $this;
	}
	
	public function exec($params = array()) {
		if (func_num_args())
			$this->params = array_merge($this->params,$params);
		return new _F_EXTENSION_DATA_RESULT_SET_(
			$this->db,get_object_vars($this),
			$this->params,$this->class);
	}

}

